/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package motiveai.components;

import motiveai.factors.Environment;

/**
 *
 * @author oxplay
 */
public abstract class SensorEntity<T extends Agent> implements Entity {

    private float tpfc = 0;
    private float stimuliFactor = 0;

    /*
     * Set updateFramerate 1f - one second
     */
    public void setStimuliFactor(float stimuliFactor) {
        this.stimuliFactor = stimuliFactor;
    }

    /*
     * Get updateFramerate
     */
    public float getStimuliFactor() {
        return stimuliFactor;
    }

    /*
     * Should modify Agent Environment
     */
    protected abstract void examEnvironment(T agent, Environment environment);

    public void update(float tpf, T agent, Environment agentEnvironment) {
        tpfc += tpf;
        if (tpfc >= stimuliFactor) {
            tpfc = 0;
            agent.setAgentEnvironment(agentEnvironment);
            examEnvironment(agent, agentEnvironment);
        }
    }
}
